(function () {
    "use strict";

    angular.module('core').factory('condicaoPagamentoService', factory);
    factory.$inject = ['$http', '$q'];

    function factory($http, $q) {

        return {

            get: function (id) {
            var deferred = $q.defer();
            $http.post('/condicaopagamento/get', id)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        },
            getAll: function (args) {
            var deferred = $q.defer();
            $http.post('/condicaopagamento/getall', args)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        },
            count: function (args) {
            var deferred = $q.defer();
            $http.post('/condicaopagamento/count', args)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        },

            prepareNew: function () {
                var deferred = $q.defer();
                $http.post('/condicaopagamento/prepareNew')
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            prepareNewParcela: function (item) {
            var deferred = $q.defer();
            $http.post('/condicaopagamento/PrepareNewParcela', item)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        },

            prepare: function (item) {
                var deferred = $q.defer();
                $http.post('/condicaopagamento/prepare', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            save: function (item) {
            var deferred = $q.defer();
            $http.post('/condicaopagamento/save', item)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        },
            delete: function (args) {
            var deferred = $q.defer();
            $http.post('/condicaopagamento/delete', args)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        }
        };
    }

})();


